package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /**
     * 动态条件查询套餐
     * @param setmeal
     * @return
     */
    List<Setmeal> list(Setmeal setmeal);

    /**
     * 根据菜品Id来查询套餐id
     * @param dishIds
     * @return
     */
    //select setmeal_id from setmeal_dish where dish_id in (1,2,3,4,...)//批量查找
    List<Long> getSetmealIdsByDishIds(List<Long> dishIds);

    /**
     * 插入n条套餐与菜品的关系
     * @param setmealDishes
     */
    @AutoFill(OperationType.INSERT)
    void insertBatch(List<SetmealDish> setmealDishes);

    /**
     * 根据套餐id查询套餐与菜品的关系信息
     * @param setmealid
     * @return
     */
    List<SetmealDish> getByid(Long setmealid);

    /**
     * 根据套餐id来删除菜品和套餐的关系
     * @param setmealid
     */
    @Delete("delete from sky_take_out.setmeal_dish where setmeal_id =setmeal_id")
    void deleteBysetmealId(Long setmealid);
}
